package com.hao.tool.extra.poi.excel;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileOutputStream;

/**
 * 保存文件工具类
 * Created by RuiHaoZ on 2018/3/26 21:01
 */
public class FileSaveUtil {
    private static Logger logger = LoggerFactory.getLogger(FileSaveUtil.class);


    /**
     * @param workbook       表格对象
     * @param nativeFileName 存储的文件路径（服务器中）
     */
    public static void saveFileOnLocal(HSSFWorkbook workbook, String nativeFileName) {
        try {

            FileOutputStream outputStream = new FileOutputStream(nativeFileName);
            workbook.write(outputStream);
            outputStream.close();
            logger.info("文件生成到本地[{}]", nativeFileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
